package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

/**
 * Auther:ws@itany.com
 * Date:20-9-16 下午5:11
 * Version:1.0
 * Description:
 */
@Controller
@RequestMapping("/respose")
public class ResposeController {
    @RequestMapping("f1")
    public String f1(){
        return "login";
    }
    @RequestMapping("f2")
    public String f2(){
        return "redirect:/showLogin";
    }
    @RequestMapping("f3")
    public String f3(){
        return "forward:/showLogin";
    }
    @RequestMapping("f4")
    public void f4(){
        System.out.print("44444444444");
    }
    @RequestMapping("f5")
    public void f5(HttpServletResponse response) throws IOException {
        PrintWriter writer = response.getWriter();
        writer.print("55555555");
    }

    @ResponseBody
    @RequestMapping("f6")
    public String f5(){
        return "<h1>f6</h1>";
    }

    @RequestMapping("/f7")
    public void f7(HttpServletRequest request) throws UnsupportedEncodingException {
        request.setCharacterEncoding("utf-8");
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println("username:"+username+",password:"+password);
    }

    @RequestMapping("/f8")
    public void f8(@RequestParam("username") String username, @RequestParam("password") String password){
        System.out.println("username:"+username+",password:"+password);
    }
}
